using Microsoft.Xna.Framework;

namespace Blood_Siege
{
    //The main menu screen is the first thing displayed when the game starts up.
    class MainMenuScreen : MenuScreen
    {

        //Constructor fills in the menu contents.
        public MainMenuScreen() : base("Main Menu")
        {
            // Create our menu entries.
            MenuEntry NewGameMenuEntry = new MenuEntry("New Game");
            MenuEntry LoadGameMenuEntry = new MenuEntry("Load Game");
            MenuEntry MultiplayerMenuEntry = new MenuEntry("Multiplayer");
            MenuEntry optionsMenuEntry = new MenuEntry("Options");
            MenuEntry exitMenuEntry = new MenuEntry("Exit");

            // Hook up menu event handlers.
            NewGameMenuEntry.Selected += NewGameMenuEntrySelected;
            LoadGameMenuEntry.Selected += LoadGameMenuEntrySelected;
            MultiplayerMenuEntry.Selected += MultiplayerMenuEntrySelected;
            optionsMenuEntry.Selected += OptionsMenuEntrySelected;
            exitMenuEntry.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(NewGameMenuEntry);
            MenuEntries.Add(LoadGameMenuEntry);
            MenuEntries.Add(MultiplayerMenuEntry);
            MenuEntries.Add(optionsMenuEntry);
            MenuEntries.Add(exitMenuEntry);
        }

        //Event handler for when the Play Game menu entry is selected.
        void NewGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            LoadingScreen.Load(StateManager, true, e.PlayerIndex, new GameplayScreen());
        }

        void LoadGameMenuEntrySelected(object sener, PlayerIndexEventArgs e)
        {
            StateManager.AddScreen(new LoadGameScreen(), e.PlayerIndex);
        }

        void MultiplayerMenuEntrySelected(object sener, PlayerIndexEventArgs e)
        {
            StateManager.AddScreen(new MultiplayerScreen(), e.PlayerIndex);
        }

        //Event handler for when the Options menu entry is selected.
        void OptionsMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            StateManager.AddScreen(new OptionsMenuScreen(), e.PlayerIndex);
        }

        //When the user cancels the main menu, ask if they want to exit the sample.
        protected override void OnCancel(PlayerIndex playerIndex)
        {
            StateManager.Game.Exit();
        }
    }
}
